"""
    p3toVM主文件:main1f.py
    修改日期：2018/10/6
    https://gitee.com/codeman27/p3toVM
    目前p3toVM版本：v1.0-test测试版
"""


class VM:                       # define virtual machine

    def __init__(self):         # Initialization

        """
            create the virtual directory
            create a VM road # 当前路径
        """

        self.files = {
            'computer/': ['d---v', {}],
            'data/': ['d---v', {}],
            'file/': ['d---v', {}],
            'user/': ['d---v', {}],
            'package/': ['d---v', {}],
        }

        self.road = '/'
        self.now = self.files

    def go_li(self, string: str) -> list:

        """
            :param string: str
            :return: list

            the param 'string' must like '/xx/xx/.../xx/'
            then the 'road' will be the string
            and the 'now' will be the files in the road
        """

        x = self.now
        try:
            result = []
            self.road = string
            roads = self.road.split('/')
            del roads[0]
            del roads[-1]
            while roads != []:
                self.now = self.now(roads.pop(0))[1]
            result = self.now.keys()
            return result

        except:
            self.now = x
            print('No such file or directory')
            print('ERROR 0100')
            return ['ERROR0100']
    
    def create_file(self, name: str, code: str) -> int:
        
        """
            :param name: str
            :param code: str
            :return: int
            
            create a new empty file with a name and some codes
            in the 'self.now'
            codes look like '-----'
        """
        
        try:
            pass
        except:
            pass
